home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER: S5-copydir 0.1 (9.4.99)
- by Neil Bothwick
- Uses S5-trans to copy a complete Psion5 directory
- */
-
- /* ;;; Initialise */
- ScriptName = 'S5-copydir'
- options results
- address command
- if ~show('L','rexxsupport.library') then do
- if ~addlib('rexxsupport.library',0,-30,0) then call ExitMsg(ScriptName 'requires rexxsupport.library')
- end
- if ~show('L','rexxdossupport.library') then do
- if ~addlib('rexxdossupport.library',0,-30,0) then call ExitMsg(ScriptName 'requires rexxdossupport.library')
- end
- 'which >NIL: s5-dir'
- if RC > 0 then call ExitMsg('This script needs the commands from S5-trans installed in your path')
- ;;;
- /* ;;; Read arguments */
- parse arg args
- Template = 'SOURCE/A,DEST/A'
- Usage = 'Usage: S5-copydir' template
- call ReadArgs(args,template)
- if RC > 0 then call ExitMsg(Usage)
- DirCount = 0
- ;;;
- /* ;;; Copy directory */
- call CopyDir(Source,Dest)
- exit
- ;;;
- /* ;;; Read and copy a directory */
- CopyDir: procedure expose DirCount
- DirCount = DirCount + 1
- Source = arg(1)
- Dest = arg(2)
- if right(Source,1) ~= '\' then Source = Source'\'
- if ~exists(Dest) then do
- 'makedir "'Dest'"'
- if RC > 0 then call ExitMsg('Could not create directory' Dest)
- end
- ext = DirCount
- OutFile = 'T:S5-copydir.'ext
- 'S5-dir >'OutFile '"'Source'"'
- if ~open(out||ext,OutFile,'R') then call ExitMsg('Failed to read temporary file')
- do until eof(out||ext)
- line = readln(out||ext)
- if line = '' then iterate
- /*say line*/
- ItemName = subword(line,1,words(line) - 4)
- ItemType = word(line,words(line) - 3)
- ItemDate = subword(line,words(line) - 1)
- if ItemType = 'Dir' then call CopyDir(Source||ItemName,AddPart(Dest,ItemName))
- else do
- say 'Copying' Source||ItemName'...'
- 'S5-get >NIL: "'Source||ItemName'"' '"'AddPart(Dest,ItemName)'"'
- /*call delay(10)*/
- 'setdate >NIL:' '"'AddPart(Dest,ItemName)'"' ItemDate
- end
- end
- call close(out||ext)
- call delete(OutFile)
- return
- ;;;
- /* ;;; Exit with a message */
- ExitMsg:
- parse arg msg
- say msg
- if msg = Usage then exit
- exit 10
- ;;;
-